package org.xmap.util;

public final class StringUtil {

    public static String removeChar(String source, char c) {
        if (source != null) {
            StringBuffer sb = null;
            while (true) {
                int index = source.indexOf(c);
                if (index != -1) {
                    if (sb == null) {
                        sb = new StringBuffer(source.length());
                    }
                    if (index != 0) {
                        sb.append(source.substring(0, index));
                    }
                    source = source.substring(index + 1, source.length());
                } else {
                    if (sb == null) {
                        return source;
                    } else {
                        sb.append(source);
                        return sb.toString();
                    }
                }
            }
        }
        return null;
    }
}